package com.right.health.app.utils;

import java.util.Calendar;
import java.util.Date;

/*
 * Created by hopeliao on 2019-12-20
 *
 */public class WeekUtils {

    /**
     * 星期几
     *
     * Date 日期
     * @return 星期一到星期日
     *
     * */
    public static String getWeekOfDate(Date date) {
        String[] weekDays = { "周末", "周一", "周二", "周三", "周四", "周五", "周六" };
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if (w < 0)
            w = 0;

        return weekDays[w];
    }

    /**
     * 星期几
     *
     * @param time
     * long 系统时间的long类型
     * @return 星期一到星期日
     *
     * */
    public static String getWeekOfDate(long time) {
        Date date = new Date(time);
        return getWeekOfDate(date);
    }

}
